package com.aabte.design.pattern.structural.flyweight;

import java.util.Hashtable;
import java.util.Map;

public class EmployeeFactory {

    private static final Map<String, Employee> EMPLOYEE_MAP = new Hashtable<>();

    public static Employee getManager(String department){

        Manager manager = (Manager) EMPLOYEE_MAP.get(department);

        if (null == manager) {
            manager = new Manager(department);
            System.out.println("创建部门经理：" + department);
            String reportContent = department+"部门汇报：此次报告的主要内容...";
            manager.setReportContent(reportContent);
            System.out.println("创建报告：" + reportContent);
            EMPLOYEE_MAP.put(department, manager);

        }

        return manager;
    }

}
